/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 08
 * Time: 15:32
 */




import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;



class DeleteBorrow {



    /**

     * 删除id最大的一条借阅记录

     */

    public static void main(String[] args) {

        Connection    connection    = null;

        PreparedStatement preparedStatement = null;

        try {

            connection = Util.getConnection();

            String sql = "delete from borrow_info where id =" +

                    "(select r.id from (select max(id) id from borrow_info) r)";

            preparedStatement = connection.prepareStatement(sql);

            int result = preparedStatement.executeUpdate();

            System.out.println(result);

        } catch (SQLException e) {

            e.printStackTrace();

        } finally {

            Util.close(null, preparedStatement, connection);

        }

    }

}